package com.fr.dialog.core;

import com.fr.base.FRContext;
import com.fr.base.Inter;
import com.fr.base.background.Background;
import com.fr.base.background.ColorBackground;
import com.fr.base.background.GradientBackground;
import com.fr.base.background.ImageBackground;
import com.fr.base.background.PatternBackground;
import com.fr.base.background.TextureBackground;
import com.fr.base.core.ComparatorUtils;
import com.fr.base.core.GraphHelper;
import com.fr.cell.core.GUICoreUtils;
import com.fr.cell.core.JNumberField;
import com.fr.cell.core.layout.LayoutFactory;
import com.fr.dialog.BasicPane;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.TexturePaint;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyListener;
import java.awt.geom.Rectangle2D.Double;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JToggleButton;
import javax.swing.Spring;
import javax.swing.SpringLayout;
import javax.swing.SpringLayout.Constraints;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.EventListenerList;

public class BackgroundPane extends BasicPane
{
  private JTabbedPane tabbedPane = null;
  private NullBackgroundPane nullBackgroundPane = null;
  private ColorBackgroundPane colorBackgroundPane = null;
  private TextureBackgroundPane textureBackgroundPane = null;
  private PatternBackgroundPane patternBackgroundPane = null;
  private ImageBackgroundPane imageBackgroundPane = null;
  private GradientPane gradientPane = null;
  private EventListenerList eventChangeList = new EventListenerList();
  private ChangeListener backgroundChangeListener = new ChangeListener(this)
  {
    private final BackgroundPane this$0;

    public void stateChanged()
    {
      BackgroundPane.access$000(this.this$0).setBackgroundObject(this.this$0.update());
      BackgroundPane.access$000(this.this$0).repaint();
    }
  };
  private BackgroundPreviewLabel previewPane = null;
  static TexturePaint[] EmbedTexturePaintArray = { TextureBackground.NewsprintTexturePaint, TextureBackground.RecycledPaperTexturePaint, TextureBackground.ParchmentTexturePaint, TextureBackground.StationeryTexturePaint, TextureBackground.GreenMarbleTexturePaint, TextureBackground.WhiteMarbleTexturePaint, TextureBackground.BrownMarbleTexturePaint, TextureBackground.GraniteTexturePaint, TextureBackground.BlueTissuePaperTexturePaint, TextureBackground.PinkTissuePaperTexturePaint, TextureBackground.PurpleMeshTexturePaint, TextureBackground.BouquetTexturePaint, TextureBackground.PapyrusTexturePaint, TextureBackground.CanvasTexturePaint, TextureBackground.DenimTexturePaint, TextureBackground.WovenMatTexturePaint, TextureBackground.WaterDropletsTexturePaint, TextureBackground.PaperBagTexturePaint, TextureBackground.FishFossilTexturePaint, TextureBackground.SandTexturePaint, TextureBackground.CorkTexturePaint, TextureBackground.WalnutTexturePaint, TextureBackground.OakTexturePaint, TextureBackground.MediumWoodTexturePaint };
  static String[] EmbedTexturePaintDesArray = { Inter.getLocText("BackgroundTexture-Newsprint"), Inter.getLocText("BackgroundTexture-RecycledPaper"), Inter.getLocText("BackgroundTexture-Parchment"), Inter.getLocText("BackgroundTexture-Stationery"), Inter.getLocText("BackgroundTexture-GreenMarble"), Inter.getLocText("BackgroundTexture-WhiteMarble"), Inter.getLocText("BackgroundTexture-BrownMarble"), Inter.getLocText("BackgroundTexture-Granite"), Inter.getLocText("BackgroundTexture-BlueTissuePaper"), Inter.getLocText("BackgroundTexture-PinkTissuePaper"), Inter.getLocText("BackgroundTexture-PurpleMesh"), Inter.getLocText("BackgroundTexture-Bouquet"), Inter.getLocText("BackgroundTexture-Papyrus"), Inter.getLocText("BackgroundTexture-Canvas"), Inter.getLocText("BackgroundTexture-Denim"), Inter.getLocText("BackgroundTexture-WovenMat"), Inter.getLocText("BackgroundTexture-WaterDroplets"), Inter.getLocText("BackgroundTexture-PaperBag"), Inter.getLocText("BackgroundTexture-FishFossil"), Inter.getLocText("BackgroundTexture-Sand"), Inter.getLocText("BackgroundTexture-Cork"), Inter.getLocText("BackgroundTexture-Walnut"), Inter.getLocText("BackgroundTexture-Oak"), Inter.getLocText("BackgroundTexture-MediumWood") };

  public BackgroundPane()
  {
    initComponents();
  }

  protected void initComponents()
  {
    setLayout(LayoutFactory.createBorderLayout());
    this.previewPane = new BackgroundPreviewLabel();
    this.previewPane.addBackgroundChangeListener(new ChangeListener(this)
    {
      private final BackgroundPane this$0;

      public void stateChanged()
      {
        this.this$0.fireStateChanged();
      }
    });
    this.tabbedPane = new JTabbedPane();
    add(this.tabbedPane, "Center");
    this.tabbedPane.addTab(Inter.getLocText("Background-Null"), new JPanel());
    this.tabbedPane.addTab(Inter.getLocText("Color"), new JPanel());
    this.tabbedPane.addTab(Inter.getLocText("Background-Texture"), new JPanel());
    this.tabbedPane.addTab(Inter.getLocText("Background-Pattern"), new JPanel());
    this.tabbedPane.addTab(Inter.getLocText("Image"), new JPanel());
    this.tabbedPane.addTab("渐变色", new JPanel());
    this.tabbedPane.addChangeListener(this.backgroundChangeListener);
    this.tabbedPane.setPreferredSize(new Dimension(200, 210));
  }

  public void addChangeListener(ChangeListener paramChangeListener)
  {
    this.eventChangeList.add(ChangeListener.class, paramChangeListener);
  }

  public void fireStateChanged()
  {
    Object[] arrayOfObject = this.eventChangeList.getListenerList();
    ChangeEvent localChangeEvent = null;
    for (int i = arrayOfObject.length - 2; i >= 0; i -= 2)
      if (arrayOfObject[i] == ChangeListener.class)
      {
        if (localChangeEvent == null)
          localChangeEvent = new ChangeEvent(this);
        ((ChangeListener)arrayOfObject[(i + 1)]).stateChanged(localChangeEvent);
      }
  }

  private NullBackgroundPane getNullBackgroundPane()
  {
    if (this.nullBackgroundPane == null)
    {
      this.nullBackgroundPane = new NullBackgroundPane(this);
      this.nullBackgroundPane.addChangeListener(this.backgroundChangeListener);
    }
    return this.nullBackgroundPane;
  }

  private ColorBackgroundPane getColorBackgroundPane()
  {
    if (this.colorBackgroundPane == null)
    {
      this.colorBackgroundPane = new ColorBackgroundPane(this);
      this.colorBackgroundPane.addChangeListener(this.backgroundChangeListener);
    }
    return this.colorBackgroundPane;
  }

  private TextureBackgroundPane getTextureBackgroundPane()
  {
    if (this.textureBackgroundPane == null)
    {
      this.textureBackgroundPane = new TextureBackgroundPane(this);
      this.textureBackgroundPane.addChangeListener(this.backgroundChangeListener);
    }
    return this.textureBackgroundPane;
  }

  private PatternBackgroundPane getPatternBackgroundPane()
  {
    if (this.patternBackgroundPane == null)
    {
      this.patternBackgroundPane = new PatternBackgroundPane(this);
      this.patternBackgroundPane.addChangeListener(this.backgroundChangeListener);
    }
    return this.patternBackgroundPane;
  }

  private ImageBackgroundPane getImageBackgroundPane()
  {
    if (this.imageBackgroundPane == null)
    {
      this.imageBackgroundPane = new ImageBackgroundPane(this);
      this.imageBackgroundPane.addChangeListener(this.backgroundChangeListener);
    }
    return this.imageBackgroundPane;
  }

  private GradientPane getGradientPane()
  {
    if (this.gradientPane == null)
    {
      this.gradientPane = new GradientPane();
      this.gradientPane.addChangeListener(this.backgroundChangeListener);
    }
    return this.gradientPane;
  }

  public void populate(Background paramBackground)
  {
    if (paramBackground == null)
    {
      this.tabbedPane.setComponentAt(0, getNullBackgroundPane());
      this.tabbedPane.setSelectedIndex(0);
      this.nullBackgroundPane.populate(paramBackground);
    }
    else if (paramBackground instanceof ColorBackground)
    {
      this.tabbedPane.setComponentAt(1, getColorBackgroundPane());
      this.tabbedPane.setSelectedIndex(1);
      this.colorBackgroundPane.populate(paramBackground);
    }
    else if (paramBackground instanceof TextureBackground)
    {
      this.tabbedPane.setComponentAt(2, getTextureBackgroundPane());
      this.tabbedPane.setSelectedIndex(2);
      this.textureBackgroundPane.populate(paramBackground);
    }
    else if (paramBackground instanceof PatternBackground)
    {
      this.tabbedPane.setComponentAt(3, getPatternBackgroundPane());
      this.tabbedPane.setSelectedIndex(3);
      this.patternBackgroundPane.populate(paramBackground);
    }
    else if (paramBackground instanceof ImageBackground)
    {
      this.tabbedPane.setComponentAt(4, getImageBackgroundPane());
      this.tabbedPane.setSelectedIndex(4);
      this.imageBackgroundPane.populate(paramBackground);
    }
    else if (paramBackground instanceof GradientBackground)
    {
      this.tabbedPane.setComponentAt(5, getGradientPane());
      this.tabbedPane.setSelectedIndex(5);
      this.gradientPane.populate(paramBackground);
    }
    this.tabbedPane.doLayout();
    this.tabbedPane.validate();
  }

  public Background update()
  {
    Object localObject;
    try
    {
      localObject = this.tabbedPane.getSelectedComponent();
      if (localObject.getClass() == JPanel.class)
      {
        int i = this.tabbedPane.getSelectedIndex();
        if (i == 0)
          localObject = getNullBackgroundPane();
        else if (i == 1)
          localObject = getColorBackgroundPane();
        else if (i == 2)
          localObject = getTextureBackgroundPane();
        else if (i == 3)
          localObject = getPatternBackgroundPane();
        else if (i == 4)
          localObject = getImageBackgroundPane();
        else if (i == 5)
          localObject = getGradientPane();
        this.tabbedPane.setComponentAt(i, (Component)localObject);
      }
      if (localObject instanceof BackgroundSettingPane)
        return ((BackgroundSettingPane)localObject).update();
      if (localObject instanceof GradientPane)
        return ((GradientPane)localObject).update();
    }
    catch (Exception localException)
    {
      FRContext.getLogger().log(Level.WARNING, localException.getMessage(), localException);
    }
    return ((Background)null);
  }

  static BackgroundPreviewLabel access$000(BackgroundPane paramBackgroundPane)
  {
    return paramBackgroundPane.previewPane;
  }

  class ImageBackgroundPane extends BackgroundPane.BackgroundSettingPane
  {
    private ImagePreviewPane previewPane;
    private javax.swing.JRadioButton defaultRadioButton;
    private javax.swing.JRadioButton centerRadioButton;
    private javax.swing.JRadioButton extendRadioButton;
    private javax.swing.JRadioButton tiledRadioButton;
    private ChangeListener changeListener;
    private ImageFileChooser imageFileChooser;
    private JLabel imageSizeLabel;
    private JCheckBox specifySizeCheckBox;
    private JPanel southImageSizePane;
    private JNumberField widthNumberField;
    private JNumberField heightNumberField;
    ActionListener selectPictureActionListener;
    KeyListener widthHeightKeyListener;
    ActionListener layoutActionListener;
    ChangeListener imageSizeChangeListener;
    private final BackgroundPane this$0;

    public ImageBackgroundPane()
    {
      super(paramBackgroundPane);
      this.this$0 = paramBackgroundPane;
      this.previewPane = null;
      this.defaultRadioButton = null;
      this.centerRadioButton = null;
      this.extendRadioButton = null;
      this.tiledRadioButton = null;
      this.changeListener = null;
      this.imageFileChooser = null;
      this.imageSizeLabel = new JLabel();
      this.selectPictureActionListener = new BackgroundPane.5(this);
      this.widthHeightKeyListener = new BackgroundPane.6(this);
      this.layoutActionListener = new BackgroundPane.7(this);
      this.imageSizeChangeListener = new BackgroundPane.8(this);
      setLayout(new BorderLayout(0, 0));
      JPanel localJPanel1 = new JPanel();
      add(localJPanel1, "Center");
      localJPanel1.setLayout(new BorderLayout(0, 0));
      JPanel localJPanel2 = new JPanel();
      localJPanel1.add(localJPanel2, "Center");
      localJPanel2.setBorder(BorderFactory.createTitledBorder(Inter.getLocText("Preview")));
      localJPanel2.setLayout(LayoutFactory.createBorderLayout());
      this.previewPane = new ImagePreviewPane();
      localJPanel2.add(new JScrollPane(this.previewPane));
      this.previewPane.addChangeListener(this.imageSizeChangeListener);
      JPanel localJPanel3 = new JPanel();
      localJPanel1.add(localJPanel3, "East");
      localJPanel3.setLayout(LayoutFactory.createBorderLayout());
      localJPanel3.setBorder(BorderFactory.createEmptyBorder(8, 2, 4, 0));
      JButton localJButton = new JButton(Inter.getLocText("Image-Select_Picture"));
      localJPanel3.add(localJButton, "North");
      localJButton.setMnemonic('S');
      localJButton.addActionListener(this.selectPictureActionListener);
      this.imageSizeLabel.setHorizontalAlignment(0);
      localJPanel3.add(this.imageSizeLabel, "Center");
      JPanel localJPanel4 = new JPanel();
      localJPanel3.add(localJPanel4, "South");
      localJPanel4.setLayout(new BorderLayout(0, 4));
      this.specifySizeCheckBox = new JCheckBox(Inter.getLocText("Image-Specified_Size"), false);
      localJPanel4.add(this.specifySizeCheckBox, "North");
      this.specifySizeCheckBox.addActionListener(new BackgroundPane.4(this));
      this.southImageSizePane = new JPanel();
      localJPanel4.add(this.southImageSizePane, "Center");
      this.southImageSizePane.setLayout(new SpringLayout());
      this.widthNumberField = new JNumberField();
      this.widthNumberField.setColumns(4);
      this.widthNumberField.addKeyListener(this.widthHeightKeyListener);
      this.southImageSizePane.add(new JLabel(Inter.getLocText("Width") + ":"));
      this.southImageSizePane.add(this.widthNumberField);
      this.widthNumberField.setEnabled(false);
      this.heightNumberField = new JNumberField();
      this.heightNumberField.setColumns(4);
      this.heightNumberField.addKeyListener(this.widthHeightKeyListener);
      this.southImageSizePane.add(new JLabel(Inter.getLocText("Height") + ":"));
      this.southImageSizePane.add(this.heightNumberField);
      this.heightNumberField.setEnabled(false);
      if (this.southImageSizePane.getLayout() instanceof SpringLayout)
      {
        localObject1 = (SpringLayout)this.southImageSizePane.getLayout();
        localObject2 = Spring.constant(6);
        for (int i = 0; i < 2; ++i)
        {
          Spring localSpring2 = Spring.constant(0);
          for (int k = 0; k < 2; ++k)
            localSpring2 = Spring.max(localSpring2, ((SpringLayout)localObject1).getConstraints(this.southImageSizePane.getComponent(k * 2 + i)).getWidth());
          for (k = 0; k < 2; ++k)
          {
            SpringLayout.Constraints localConstraints2 = ((SpringLayout)localObject1).getConstraints(this.southImageSizePane.getComponent(k * 2 + i));
            localConstraints2.setX((Spring)localObject2);
            localConstraints2.setWidth(localSpring2);
          }
          localObject2 = Spring.sum((Spring)localObject2, Spring.sum(localSpring2, Spring.constant(2)));
        }
        Spring localSpring1 = Spring.constant(6);
        for (int j = 0; j < 2; ++j)
        {
          Spring localSpring3 = Spring.constant(0);
          for (int l = 0; l < 2; ++l)
            localSpring3 = Spring.max(localSpring3, ((SpringLayout)localObject1).getConstraints(this.southImageSizePane.getComponent(j * 2 + l)).getHeight());
          for (l = 0; l < 2; ++l)
          {
            SpringLayout.Constraints localConstraints3 = ((SpringLayout)localObject1).getConstraints(this.southImageSizePane.getComponent(j * 2 + l));
            localConstraints3.setY(localSpring1);
            localConstraints3.setHeight(localSpring3);
          }
          localSpring1 = Spring.sum(localSpring1, Spring.sum(localSpring3, Spring.constant(2)));
        }
        SpringLayout.Constraints localConstraints1 = ((SpringLayout)localObject1).getConstraints(this.southImageSizePane);
        localConstraints1.setConstraint("South", localSpring1);
        localConstraints1.setConstraint("East", (Spring)localObject2);
      }
      else
      {
        GUICoreUtils.setEnabled(this.southImageSizePane, false);
      }
      Object localObject1 = new JPanel();
      add((Component)localObject1, "South");
      ((JPanel)localObject1).setBorder(BorderFactory.createTitledBorder(Inter.getLocText("Image-Layout")));
      ((JPanel)localObject1).setLayout(new GridLayout(1, 3));
      this.defaultRadioButton = new javax.swing.JRadioButton(Inter.getLocText("Default"));
      this.tiledRadioButton = new javax.swing.JRadioButton(Inter.getLocText("Image-Titled"));
      this.centerRadioButton = new javax.swing.JRadioButton(Inter.getLocText("Center"));
      this.extendRadioButton = new javax.swing.JRadioButton(Inter.getLocText("Image-Extend"));
      this.defaultRadioButton.setMnemonic('D');
      this.tiledRadioButton.setMnemonic('T');
      this.centerRadioButton.setMnemonic('C');
      this.extendRadioButton.setMnemonic('E');
      this.defaultRadioButton.addActionListener(this.layoutActionListener);
      this.tiledRadioButton.addActionListener(this.layoutActionListener);
      this.centerRadioButton.addActionListener(this.layoutActionListener);
      this.extendRadioButton.addActionListener(this.layoutActionListener);
      this.defaultRadioButton.setHorizontalAlignment(0);
      this.tiledRadioButton.setHorizontalAlignment(0);
      this.centerRadioButton.setHorizontalAlignment(0);
      this.extendRadioButton.setHorizontalAlignment(0);
      ((JPanel)localObject1).add(this.defaultRadioButton);
      ((JPanel)localObject1).add(this.tiledRadioButton);
      ((JPanel)localObject1).add(this.centerRadioButton);
      ((JPanel)localObject1).add(this.extendRadioButton);
      Object localObject2 = new ButtonGroup();
      ((ButtonGroup)localObject2).add(this.defaultRadioButton);
      ((ButtonGroup)localObject2).add(this.tiledRadioButton);
      ((ButtonGroup)localObject2).add(this.centerRadioButton);
      ((ButtonGroup)localObject2).add(this.extendRadioButton);
      this.defaultRadioButton.setSelected(true);
      this.imageFileChooser = new ImageFileChooser();
      this.imageFileChooser.setMultiSelectionEnabled(false);
    }

    public void populate()
    {
      this.specifySizeCheckBox.setSelected(false);
      if (paramBackground instanceof ImageBackground)
      {
        ImageBackground localImageBackground = (ImageBackground)paramBackground;
        if (localImageBackground.getLayout() == 1)
          this.centerRadioButton.setSelected(true);
        else if (localImageBackground.getLayout() == 2)
          this.extendRadioButton.setSelected(true);
        else if (localImageBackground.getLayout() == 3)
          this.defaultRadioButton.setSelected(true);
        else
          this.tiledRadioButton.setSelected(true);
        if (localImageBackground.getImage() != null)
        {
          this.previewPane.setImage(localImageBackground.getImage());
          this.imageSizeLabel.setText(this.previewPane.getImage().getWidth(null) + " X " + this.previewPane.getImage().getHeight(null));
        }
        this.widthNumberField.setValue(-1.0D);
        this.heightNumberField.setValue(-1.0D);
        if (localImageBackground.getImage() != null)
        {
          this.previewPane.setImage(localImageBackground.getImage());
          if ((localImageBackground.getSpecifiedImageWidth() != -1.0D) && (localImageBackground.getSpecifiedImageHeight() != -1.0D))
          {
            this.specifySizeCheckBox.setSelected(true);
            this.widthNumberField.setValue(localImageBackground.getSpecifiedImageWidth());
            this.heightNumberField.setValue(localImageBackground.getSpecifiedImageHeight());
          }
        }
      }
      else
      {
        this.previewPane.setImage(null);
        this.tiledRadioButton.setSelected(true);
        this.imageSizeLabel.setText("");
      }
      if (this.specifySizeCheckBox.isSelected())
        GUICoreUtils.setEnabled(this.southImageSizePane, true);
      else
        GUICoreUtils.setEnabled(this.southImageSizePane, false);
      fireChagneListener();
    }

    public Background update()
      throws Exception
    {
      ImageBackground localImageBackground = new ImageBackground(this.previewPane.getImage());
      if (this.specifySizeCheckBox.isSelected())
      {
        if (this.widthNumberField.getValue() < 0.0D)
          localImageBackground.setSpecifiedImageWidth(this.previewPane.getImage().getWidth(null));
        else
          localImageBackground.setSpecifiedImageWidth(this.widthNumberField.getValue());
        if (this.heightNumberField.getValue() < 0.0D)
          localImageBackground.setSpecifiedImageHeight(this.previewPane.getImage().getHeight(null));
        else
          localImageBackground.setSpecifiedImageHeight(this.heightNumberField.getValue());
      }
      else
      {
        this.widthNumberField.setValue(-1.0D);
        this.heightNumberField.setValue(-1.0D);
      }
      if (this.tiledRadioButton.isSelected())
        localImageBackground.setLayout(0);
      else if (this.centerRadioButton.isSelected())
        localImageBackground.setLayout(1);
      else if (this.extendRadioButton.isSelected())
        localImageBackground.setLayout(2);
      else
        localImageBackground.setLayout(3);
      return localImageBackground;
    }

    public void addChangeListener()
    {
      this.changeListener = paramChangeListener;
    }

    private void fireChagneListener()
    {
      if (this.changeListener != null)
      {
        ChangeEvent localChangeEvent = new ChangeEvent(this);
        this.changeListener.stateChanged(localChangeEvent);
      }
    }

    static JCheckBox access$600(ImageBackgroundPane paramImageBackgroundPane)
    {
      return paramImageBackgroundPane.specifySizeCheckBox;
    }

    static JPanel access$700(ImageBackgroundPane paramImageBackgroundPane)
    {
      return paramImageBackgroundPane.southImageSizePane;
    }

    static ImageFileChooser access$800(ImageBackgroundPane paramImageBackgroundPane)
    {
      return paramImageBackgroundPane.imageFileChooser;
    }

    static ImagePreviewPane access$900(ImageBackgroundPane paramImageBackgroundPane)
    {
      return paramImageBackgroundPane.previewPane;
    }

    static void access$1000(ImageBackgroundPane paramImageBackgroundPane)
    {
      paramImageBackgroundPane.fireChagneListener();
    }

    static JLabel access$1100(ImageBackgroundPane paramImageBackgroundPane)
    {
      return paramImageBackgroundPane.imageSizeLabel;
    }
  }

  class PatternBackgroundPane extends BackgroundPane.BackgroundSettingPane
  {
    private int patternIndex;
    private ColorSelectionPane foregroundColorPane;
    private ColorSelectionPane backgroundColorPane;
    private PatternButton[] patternButtonArray;
    ChangeListener colorChangeListener;
    private final BackgroundPane this$0;

    public PatternBackgroundPane()
    {
      super(paramBackgroundPane);
      this.this$0 = paramBackgroundPane;
      this.patternIndex = 0;
      this.colorChangeListener = new BackgroundPane.3(this);
      initComponents();
    }

    protected void initComponents()
    {
      setLayout(LayoutFactory.createBorderLayout());
      setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
      JPanel localJPanel1 = new JPanel();
      add(localJPanel1, "North");
      localJPanel1.setLayout(new BoxLayout(localJPanel1, 1));
      JPanel localJPanel2 = new JPanel();
      localJPanel1.add(localJPanel2);
      localJPanel2.setLayout(new FlowLayout(1, 2, 3));
      localJPanel2.setBorder(BorderFactory.createTitledBorder(Inter.getLocText("Background-Pattern")));
      JPanel localJPanel3 = new JPanel();
      localJPanel2.add(localJPanel3);
      localJPanel3.setLayout(new GridLayout(4, 12, 4, 2));
      ButtonGroup localButtonGroup = new ButtonGroup();
      this.patternButtonArray = new PatternButton[48];
      for (int i = 0; i < 48; ++i)
      {
        this.patternButtonArray[i] = new PatternButton(this, i);
        localButtonGroup.add(this.patternButtonArray[i]);
        localJPanel3.add(this.patternButtonArray[i]);
      }
      JPanel localJPanel4 = new JPanel();
      localJPanel1.add(localJPanel4);
      localJPanel4.setLayout(new FlowLayout(1, 12, 6));
      localJPanel4.setBorder(BorderFactory.createTitledBorder(Inter.getLocText("Colors")));
      localJPanel4.setLayout(new BoxLayout(localJPanel4, 0));
      this.foregroundColorPane = new ColorSelectionPane(80);
      this.backgroundColorPane = new ColorSelectionPane(80);
      this.backgroundColorPane.setCanBeNull(true);
      this.foregroundColorPane.setColor(Color.lightGray);
      this.backgroundColorPane.setColor(Color.black);
      this.foregroundColorPane.addColorChangeListener(this.colorChangeListener);
      this.backgroundColorPane.addColorChangeListener(this.colorChangeListener);
      localJPanel4.add(Box.createHorizontalStrut(2));
      localJPanel4.add(createLabelColorPane(Inter.getLocText("Foreground") + ":", this.foregroundColorPane));
      localJPanel4.add(Box.createHorizontalStrut(8));
      localJPanel4.add(createLabelColorPane(Inter.getLocText("Background") + ":", this.backgroundColorPane));
    }

    private JPanel createLabelColorPane(, ColorSelectionPane paramColorSelectionPane)
    {
      JPanel localJPanel = new JPanel();
      localJPanel.setLayout(new FlowLayout(1, 2, 0));
      localJPanel.add(new JLabel(paramString));
      localJPanel.add(paramColorSelectionPane);
      return localJPanel;
    }

    public void populate()
    {
      if ((paramBackground != null) && (paramBackground instanceof PatternBackground))
      {
        PatternBackground localPatternBackground = (PatternBackground)paramBackground;
        int i = localPatternBackground.getPatternIndex();
        if ((i >= 0) && (i < this.patternButtonArray.length))
        {
          this.patternButtonArray[i].setSelected(true);
          this.patternIndex = i;
        }
        else
        {
          this.patternIndex = 0;
        }
        this.foregroundColorPane.setColor(localPatternBackground.getForeground());
        this.backgroundColorPane.setColor(localPatternBackground.getBackground());
      }
      else
      {
        this.patternIndex = 0;
        this.patternButtonArray[0].setSelected(true);
        this.foregroundColorPane.setColor(Color.lightGray);
        this.backgroundColorPane.setColor(Color.black);
      }
    }

    public Background update()
      throws Exception
    {
      return new PatternBackground(this.patternIndex, this.foregroundColorPane.getColor(), this.backgroundColorPane.getColor());
    }

    public void addChangeListener()
    {
      this.foregroundColorPane.addColorChangeListener(paramChangeListener);
      this.backgroundColorPane.addColorChangeListener(paramChangeListener);
      for (int i = 0; i < this.patternButtonArray.length; ++i)
        this.patternButtonArray[i].addChangeListener(paramChangeListener);
    }

    static PatternButton[] access$200(PatternBackgroundPane paramPatternBackgroundPane)
    {
      return paramPatternBackgroundPane.patternButtonArray;
    }

    static ColorSelectionPane access$300(PatternBackgroundPane paramPatternBackgroundPane)
    {
      return paramPatternBackgroundPane.foregroundColorPane;
    }

    static ColorSelectionPane access$400(PatternBackgroundPane paramPatternBackgroundPane)
    {
      return paramPatternBackgroundPane.backgroundColorPane;
    }

    static int access$500(PatternBackgroundPane paramPatternBackgroundPane)
    {
      return paramPatternBackgroundPane.patternIndex;
    }

    static int access$502(PatternBackgroundPane paramPatternBackgroundPane)
    {
      return (paramPatternBackgroundPane.patternIndex = paramInt);
    }

    class PatternButton extends JToggleButton
      implements ActionListener
    {
      private int pIndex;
      private PatternBackground patternBackground;
      private final BackgroundPane.PatternBackgroundPane this$1;

      public PatternButton(, int paramInt)
      {
        this.this$1 = paramPatternBackgroundPane;
        this.pIndex = 0;
        this.pIndex = paramInt;
        addActionListener(this);
        setCursor(new Cursor(12));
        setBorder(null);
        this.patternBackground = new PatternBackground(this.pIndex, Color.lightGray, Color.black);
      }

      public void paintComponent()
      {
        Graphics2D localGraphics2D = (Graphics2D)paramGraphics;
        Dimension localDimension = getSize();
        this.patternBackground.paint(localGraphics2D, new Rectangle2D.Double(0.0D, 0.0D, localDimension.width - 1, localDimension.height - 1));
        if (this.pIndex == BackgroundPane.PatternBackgroundPane.access$500(this.this$1))
          localGraphics2D.setPaint(new Color(255, 51, 0));
        else
          localGraphics2D.setPaint(Color.gray);
        GraphHelper.draw(localGraphics2D, new Rectangle2D.Double(0.0D, 0.0D, localDimension.width - 1, localDimension.height - 1));
      }

      public Dimension getPreferredSize()
      {
        return new Dimension(24, 24);
      }

      public void setPatternForeground()
      {
        this.patternBackground.setForeground(paramColor);
      }

      public void setPatternBackground()
      {
        this.patternBackground.setBackground(paramColor);
      }

      public void actionPerformed()
      {
        BackgroundPane.PatternBackgroundPane.access$502(this.this$1, this.pIndex);
        fireChagneListener();
        this.this$1.repaint();
      }

      public void addChangeListener()
      {
        this.changeListener = paramChangeListener;
      }

      private void fireChagneListener()
      {
        if (this.changeListener != null)
        {
          ChangeEvent localChangeEvent = new ChangeEvent(this);
          this.changeListener.stateChanged(localChangeEvent);
        }
      }
    }
  }

  class TextureBackgroundPane extends BackgroundPane.BackgroundSettingPane
  {
    private TexturePaint texturePaint;
    private TextureButton[] textureButtonArray;
    private final BackgroundPane this$0;

    public TextureBackgroundPane()
    {
      super(paramBackgroundPane);
      this.this$0 = paramBackgroundPane;
      initComponents();
    }

    protected void initComponents()
    {
      setLayout(LayoutFactory.createBorderLayout());
      setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
      JPanel localJPanel1 = new JPanel();
      add(localJPanel1, "North");
      localJPanel1.setLayout(new BoxLayout(localJPanel1, 1));
      JPanel localJPanel2 = new JPanel();
      localJPanel1.add(localJPanel2);
      localJPanel2.setLayout(new FlowLayout(1, 2, 3));
      localJPanel2.setBorder(BorderFactory.createTitledBorder(Inter.getLocText("Background-Texture")));
      JPanel localJPanel3 = new JPanel();
      localJPanel2.add(localJPanel3);
      localJPanel3.setLayout(new GridLayout(3, 8, 6, 4));
      ButtonGroup localButtonGroup = new ButtonGroup();
      this.textureButtonArray = new TextureButton[BackgroundPane.EmbedTexturePaintArray.length];
      for (int i = 0; i < BackgroundPane.EmbedTexturePaintArray.length; ++i)
      {
        this.textureButtonArray[i] = new TextureButton(this, BackgroundPane.EmbedTexturePaintArray[i], BackgroundPane.EmbedTexturePaintDesArray[i]);
        localButtonGroup.add(this.textureButtonArray[i]);
        localJPanel3.add(this.textureButtonArray[i]);
      }
    }

    public void populate()
    {
      if (paramBackground instanceof TextureBackground)
      {
        TextureBackground localTextureBackground = (TextureBackground)paramBackground;
        this.texturePaint = localTextureBackground.getTexturePaint();
        int i = 0;
        while (true)
        {
          if (i >= this.textureButtonArray.length)
            return;
          if (this.textureButtonArray[i].getTexturePaint().equals(this.texturePaint))
          {
            this.textureButtonArray[i].setSelected(true);
            return;
          }
          ++i;
        }
      }
      this.textureButtonArray[0].setSelected(true);
      this.texturePaint = this.textureButtonArray[0].getTexturePaint();
    }

    public Background update()
      throws Exception
    {
      return new TextureBackground(this.texturePaint);
    }

    public void addChangeListener()
    {
      for (int i = 0; i < this.textureButtonArray.length; ++i)
        this.textureButtonArray[i].addChangeListener(paramChangeListener);
    }

    static TexturePaint access$100(TextureBackgroundPane paramTextureBackgroundPane)
    {
      return paramTextureBackgroundPane.texturePaint;
    }

    static TexturePaint access$102(TextureBackgroundPane paramTextureBackgroundPane)
    {
      return (paramTextureBackgroundPane.texturePaint = paramTexturePaint);
    }

    class TextureButton extends JToggleButton
      implements ActionListener
    {
      private TexturePaint buttonTexturePaint;
      private final BackgroundPane.TextureBackgroundPane this$1;

      public TextureButton(, TexturePaint paramTexturePaint, String paramString)
      {
        this.this$1 = paramTextureBackgroundPane;
        this.buttonTexturePaint = paramTexturePaint;
        setToolTipText(paramString);
        setCursor(new Cursor(12));
        addActionListener(this);
        setBorder(null);
      }

      public void paintComponent()
      {
        Graphics2D localGraphics2D = (Graphics2D)paramGraphics;
        Dimension localDimension = getSize();
        localGraphics2D.setPaint(this.buttonTexturePaint);
        GraphHelper.fill(localGraphics2D, new Rectangle2D.Double(0.0D, 0.0D, localDimension.width - 1, localDimension.height - 1));
        if (ComparatorUtils.equals(BackgroundPane.TextureBackgroundPane.access$100(this.this$1), this.buttonTexturePaint))
          localGraphics2D.setPaint(Color.black);
        else
          localGraphics2D.setPaint(Color.gray);
        GraphHelper.draw(localGraphics2D, new Rectangle2D.Double(0.0D, 0.0D, localDimension.width - 1, localDimension.height - 1));
      }

      public Dimension getPreferredSize()
      {
        return new Dimension(36, 32);
      }

      public TexturePaint getTexturePaint()
      {
        return this.buttonTexturePaint;
      }

      public void actionPerformed()
      {
        BackgroundPane.TextureBackgroundPane.access$102(this.this$1, getTexturePaint());
        fireChagneListener();
        this.this$1.repaint();
      }

      public void addChangeListener()
      {
        this.changeListener = paramChangeListener;
      }

      private void fireChagneListener()
      {
        if (this.changeListener != null)
        {
          ChangeEvent localChangeEvent = new ChangeEvent(this);
          this.changeListener.stateChanged(localChangeEvent);
        }
      }
    }
  }

  class ColorBackgroundPane extends BackgroundPane.BackgroundSettingPane
  {
    private DetailColorSelectPane detailColorSelectPane;
    private final BackgroundPane this$0;

    public ColorBackgroundPane()
    {
      super(paramBackgroundPane);
      this.this$0 = paramBackgroundPane;
      setLayout(LayoutFactory.createBorderLayout());
      this.detailColorSelectPane = new DetailColorSelectPane();
      add(this.detailColorSelectPane, "Center");
    }

    public void populate()
    {
      if (paramBackground instanceof ColorBackground)
      {
        ColorBackground localColorBackground = (ColorBackground)paramBackground;
        this.detailColorSelectPane.populate(localColorBackground.getColor());
      }
      else
      {
        this.detailColorSelectPane.populate(Color.white);
      }
    }

    public Background update()
      throws Exception
    {
      return ColorBackground.getInstance(this.detailColorSelectPane.update());
    }

    public void addChangeListener()
    {
      this.detailColorSelectPane.addChangeListener(paramChangeListener);
    }
  }

  class NullBackgroundPane extends BackgroundPane.BackgroundSettingPane
  {
    private final BackgroundPane this$0;

    public NullBackgroundPane()
    {
      super(paramBackgroundPane);
      this.this$0 = paramBackgroundPane;
      setLayout(LayoutFactory.createBorderLayout());
      JLabel localJLabel = new JLabel(Inter.getLocText("Background-Background_is_NULL") + "...");
      add(localJLabel);
      localJLabel.setHorizontalAlignment(0);
      localJLabel.setBorder(BorderFactory.createLineBorder(GUICoreUtils.getTitleLineBorderColor()));
    }

    public void populate()
    {
    }

    public Background update()
      throws Exception
    {
      return null;
    }

    public void addChangeListener()
    {
    }
  }

  abstract class BackgroundSettingPane extends JPanel
  {
    private final BackgroundPane this$0;

    BackgroundSettingPane()
    {
      this.this$0 = paramBackgroundPane;
    }

    public abstract void populate();

    public abstract Background update()
      throws Exception;

    public abstract void addChangeListener();
  }
}